package operation;

import student.Student;
import student.StudentList;

import java.util.Scanner;

public class FindIndexOperation implements IOperation{
    @Override
    public void work(StudentList list) {
        System.out.println("查找单个学生信息");
        System.out.println("请输入你要查找的学生的学号:->");
        Scanner sc = new Scanner(System.in);
        String stuId = sc.next();
        int i = 0;
        for(; i < list.size(); i++){
            Student stu =  list.get(i);
            if(stu.getStudentId().equals(stuId)){
                System.out.println("找到了该学生，如下：");
                System.out.println(stu);
                return;
            }
        }
        if(i == list.size()){
            System.out.println("在学生表中，未查询到该学生");

        }
    }
}
